package com.example.venue_reservation_service.controller;

import com.example.venue_reservation_service.domain.SensitiveWord;
import com.example.venue_reservation_service.dto.PageDTO;
import com.example.venue_reservation_service.dto.SensitiveWordDTO;
import com.example.venue_reservation_service.dto.WordDTO;
import com.example.venue_reservation_service.service.SensitiveWordService;
import com.example.venue_reservation_service.vo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

/**
 * 敏感词管理Controller
 */
@RestController
@RequestMapping("/word")
@CrossOrigin
@Api("敏感词管理")
@Slf4j
public class SensitiveWordController {

    @Resource
    private SensitiveWordService sensitiveWordService;

    /**
     * 分页查询敏感词列表
     */
    @ApiOperation("获取敏感词数据")
    @PostMapping("/query")
    public Result query(@RequestBody WordDTO dto) {
        return sensitiveWordService.getSensitiveWords(dto);
    }
    /**
     * 添加敏感词
     */
    @ApiOperation("添加敏感词")
    @PostMapping("/create")
    public Result create(@RequestBody SensitiveWordDTO dto) {
        log.info("添加敏感词{}", dto);
        return sensitiveWordService.addSensitiveWord(dto);
    }
    /**
     * 修改敏感词信息
     */
    @ApiOperation("修改敏感词")
    @PostMapping("/update")
    public Result update(@RequestBody SensitiveWord word) {
        return sensitiveWordService.updateSensitiveWord(word);
    }

    /**
     * 删除敏感词
     */
    @ApiOperation("移除敏感词")
    @DeleteMapping("/remove")
    public Result remove(@RequestParam("id") Integer id) {
        log.info("移除敏感词{}", id);
        return sensitiveWordService.removeSensitiveWord(id);
    }

    @ApiOperation("启用/禁用敏感词")
    @GetMapping("/set/{id}")
    public Result set(@PathVariable("id") Integer id){
        return sensitiveWordService.set(id);
    }
}
